package com.hst.capacity.infra.persistence.jpa.setting.price;

import com.hst.capacity.domain.model.entity.setting.price.ExpressCommonPriceEntity;
import com.hst.capacity.domain.model.response.setting.price.ExpressSearchVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ExCommonPriceRepository extends CrudRepository<ExpressCommonPriceEntity, Integer> {

    /**
     * 通过地区查找普通快车价格
     * @param regionCode
     * @return
     */
    ExpressCommonPriceEntity findByRegionCodeAndIdFranchisee(String regionCode, String idFranchisee);

    /**
     * 通过地区查找普通快车价格
     * @param regionCode
     * @return
     */
    List<ExpressCommonPriceEntity> findByRegionCode(String regionCode);

    @Query("select new com.hst.capacity.domain.model.response.setting.price.ExpressSearchVO(p) from ExpressCommonPriceEntity p where p.idFranchisee=:idFranchisee")
    Page<ExpressSearchVO> findByIdFranchisee(String idFranchisee, PageRequest pageRequest);

    ExpressCommonPriceEntity findByIdFranchiseeAndRegionCodeAndIdVehicleTypeAndIdServiceType(String idf,String reg,String vet,String ist);
}
